Prevent possible ClassCastException