Make pop() function which matches the documented behavior.