working collision detection for rectangle shapes