changed data structure to hash