refactor genPass method