Handling collision detection

Trying to sort out the algorithm