cleaned up map & flatmap