add support for double buffering