moved connection code to view controller