refactor with #each