fixed box checking logic