refactor webserver