added double check for scanning
some changes