Adds sorting and generation logic