merged Chenhan's changes