Refactored the token manipulation into its own module