Fixed to handle multiple scans