Automatic buffer swap