added database and file reading code