update code from Cuong