adding changes to check for collisions