refactoring and ex3