Created double buffering functions