refactoring code to decide to start the server or not