refactored db into app