refactoring the whole application