add loop helper & clean code