fix buffer switching