refactoring to ex1