new function and loop