we try to follow the convention where the first arguments are input arguments, and the last arguments are output args.