refactored inline logic out to a named function