minor OOP related changes

reclassified connection to query and added the connection object.