fix InvalidCastException