change functions to duplicate correctly (pair, local let).