Added error check for no db