refactored server into multiple files