clean and some refactoring for ex3