added checking for number of parameters