implement double-buffer