Wrote rendering code and fixed update function