Added a size check in map each