Use map instead of a clunky for-loop