need to refactor class detection