changes cleaned up code and used db_class where except for update query