draft of buffer saving code