Fixed isEmpty logic