Fixed Bugs in Backtracking

The ValidBox wasn't working correctly