Updated scan subroutine to have a loop. Updated call to scan subroutine to account for number of cycles to repeat.