Fix scope for casting