replace dangling cast with resolve