Simplify the box constraint code