Fixed logic issue in scanner.rb