Implemented token exchange logic