functioning each and map methods
functioning reduce method