Made it working with 0 in input. Should be finished now. Hurray!!!