refactored server to init with app