improved how token is checked for Ajax requests