fixed buffer and first 2 then statements