extracted token access code into library