edited lifo_func