moved hashing function out
fixed exception