can you use a sinon spy here instead of this function?