Made some refactoring