added handling error if we get error when calculate the hash