overlap removal code