Updated the code from arrays to hashes