added is_nan
code convention: always use explicit return statement