That piece of code gives the expected result for me (I assume)
Maybe some other code is conflicting with this part?
sorry, blurred some parts to keep it neutral