replace 3 separate assignments with map