changes code to use hashes insted of arrays