The pop function was all wrong