better way to loop