started modularizing scanner code