edit figure.*pp, shorten the code with more functions.