finish the main function of app