Ответ:

We were doing our homework when Dan arrived.