move and refactor github access code