...just use the code that "run scan" uses.

of course don't copy paste it, make a new proc.