Code provided with author.