extract function to render data