update + refactoring

I have done some refactoring