refactor to_boolean to use IF