write has-token? function