UPDATED with persistant connection code