refactored to include named function