separate buffer management into another file