fixed coerceToClass method