defined hash and distance method.Needs work on output.