Separated scan function into .h file