Still working out why the function scoping is failing, but Everything else appears to be working.