Modified function is about check gave numbers.
and Appended debug program.