Working on fixing db redirect code