refactoring in server and app