Fixed code so that it can be used for any number of input and any number of output parameters.