refactoring to do not reuse code