refactor variable binding

api is still not thought out!