uses list iteration instead of for-loop