function for checking token.