Moving the initialization to the top of render function.