improved database organization, added logging statements