implemented check for collision