added database functionality to main