Refactor get_classes