Optimized ShellWizard algorithm