#pop should have been replaced with #last not #first