separated db interaction logic from controllers