debugged collision detection for rectangles