Correcting a cast error