refactored start server and stop server functions