Avoid ClassCastException