move buffer init before first usage when reading top->bottom