added code to correctly order the boxes based on half boxes or full boxes