added missing return statements in db connection, added query for segments