Refactored access token code into module