move rendering and redirection to handler