fixing .length comparisons to be explicitly > 0