Refactored code to use 4 HashMaps => quicker