Add nested schemas + refactor if blocks