separated function to deal with the hash check, tested it