fixed isEmpty method