Determine key id properly