merge with Chitao's changes