Redesigning RenderPage-function to get a more clean code.