Corrected the countnum function