mostly working
remove 'globalvar' previously used for testing