uses map method instead of each