IMC interview question

Expand a querying function