fix .toLowerCase()
fix .toLowerCase()
correct result.length conditional
change whiles into ifs
fix substring typo