Update scan.py

complete this function