add check to avoid mixing empty buffers