Fix string out of bounds not taking into account the margin