proper popping of stack