Add find_pop function
Remove global variables