Fixing bug with isEmpty()