changed buffer code