Added isCollision() function