Replaced String.isEmpty() with String.length() for Java 5 compatibility