before and after DB functions added