refactored and commented gh_connect.py