swapbuffer refactored