Update function check_token and logout