Added collision detection