Added code for handling -ve and zero hops