remove alchemy global var and refactor