cast enum to avoid warning
implemented type checking to ensure that custom classes actually extend the proper base class