refactor create_server function to avoid ABC complexity max