wrote main function