create a function and a loop