Updated init function to preRender