some mild refactoring of passport