DRYed up token logic