changed genkey so that it sets key