Added count function and pulled param assembly into it's own function