move to namespace or rewrite code without global variables