alter pop api to make implementation details more flexible