the codes from Thinkjava