handle interrupt within generate func