first revision by tqchen