refactored server, tough it still doesn't work