script converted into local dynmaics, now working