refactoring and more examples