Pulled out function to open the db files