fixed small bugs in code after changing way of obtaining db conneciton