add method to ensure buffer capacity