fixed resolving references with multiple databases