moved DB functions