remove useless loops