use map instead of creating array