code for simple loop