remove global variable
change api to make it less confusing