refactoring and stubbing implementation