added collision detection
fixed merge