problem: dynamic casts not working correctly