Defensive casting