refactored getClosestColor using a map