Fix typo in loop.

also define inputs in function.