drop extra variable creation and change `map` to `map!` to prevent new array creation using `map`