Added attribution to the author of some of the code