updated connect to uses database varibles in query