refactor for oauth 2