Added error checking for hash function. Changed string formatting to .format