revise the loop better