fix bug of exploding the local variable to the global
refactor the whole framework, add support for conditional procedures