Replace length check with a check against []

length() is not constant time