quick fix
fixed up variable passing in nested functions
generalized back to working without ProcMaganer