refactored method