fix buffer detection