Corrected Length to length
corrected Length to length
corrected Length to length
fixed selectBestPatterns