Improve way of handling arguments by script

Local vars are provided as arguments, and created function shares
same signature as input function.