db interaction pull out of main