cleaned up code; added config file for database connection