Fixed the implementation of collision detection

works now!