Refactor the whole application structure