improved isEmpty and equals