HashMaps modified, whereby the code now works consistently