check valid input before converting char