finish produce the code and fixed the bugs