modification of Dr. Peng's code with assignment requirement