Changed array to hashmap, commented code