added conditional schema
refactored