refactor variable binding function