using isEmpty instead of size checking