Clean up the code in pop