added Casting code from screencast