Fixed db connection hook