added a3 and handled null buffer cases