changed scanning function to work faster on pointless scans