refactor add push/pop function