more fixing box checking errors
fixing edge logic