remove double loops