Refactored to move scanner code into its own encapsulate object