Refactoring

Some refactoring about the code!