Proper pattern matching for number input