using for-loop instead of for-in-loop