Refactored solution to destructure values from map