Modified as ShengWei's advice,but have sth to do
S