Use isEmpty() instead of length()