Fix #304 by relacing the empty() with a count()