changed buffer to char[]