finish 1.7 main function