Refactoring MageServlet