Adding a refactored version of classify