refactor bindings to work without global vars