properly handling an empty buffer