added some debugging and database connection stuff