Re-factored to change instances of 'length' to 'count'