more refactoring and clean up condition db