1st loop implementation