Fixed and simplified pop, formatted code