updating the code

found ways to reduce the overall lines of code
added a database manager class to better maintain our db connections and auto end them upon deconstruction and also add a timeout to all db connections to prevent interruptions.