Fixed db connection bug