Updated draw function to use previous frame to optimize drawing