refactor SD factory, add index example