Added length count function