move buffer to global scope