improved lc valid number using nested function