added double buffer support