using for-loop instead