Migrated scanning algorithm code to separate class.