improved database population script