changed char length comparison from to <= to ==