refactoring + registration port token generation