Ensure correct casting