each was acting as map; redefine each and used it to define map