runs as function with clearer comments
updated typo in inputname