code from the article