each loop instead of duplication