Added count function.