move $cparam variable out of if statement because it caused undeclared variable errors