refactored to use stubbed methods for testing