Wrote main function