simplified code by Yi for lambda lifting