patched BuildDatabase