resolved problem with global/local functions