handle buffer edgecase