adapting code to author's suggested changes