added double-buffering