Replaced 3d array with a HashMap