Refactor of app