static casts are evil, use dynamic ones and check for NULL