refactored initialization of buffer