Added db class and allowed the functions also be used on db object