Finish main fuctions