refactor token creation