Alocating space properly for the buffer array