parsing query string and exchanging token