added checkNum function