Improved disableBoxes function