Fixed errors on detectWords method.