Prevent ClassCastException