Added indexOf checks before removing models