Fix scanner logic problem