not necessary when we refactor the above logic using map