added first working version of collision detection