Move cond and let generation to their own functions