fix max and min count checking