main function general structure