Fixed the db call so it is usable (still not perfect)