Move render() call to fix rending issues