use clazz.cast() instead of traditional approach