modified collision to support several rectangles