fixed off by one on buffer close