step 5 implemented - although some of the passed arguments to the helper function are moved outside so that others in the scope may access them