implement key generator