fixed cast in upgrade