Fix invalid runtime cast