finish: main function