refactor hash from_schema method