milestone 33: switched code and checked for existing database.