tidied up connection.py