modified collision detection