changing for expressions to map function