refactor wiring for the -r flag for keygen