Check if val is a number first