build the createKey function