Added code to count characters