Added double buffering