fixing db closings
fixing database