changed build_db to include result type