enhance count function