refactor from_schema method into smaller parts