added validation of parameters.