count function implemented