fixed bug in removal code