Extracted collision detection into the classes