Refactoring the web server functionality