refactored for readability and to improve encapsulation

note that `checkToken` is now slightly less efficient, as we're now
always reading the entire list of tokens - that should be insignificant
though