attribution: - cayo did code and explanations - pedro formatted and edited to inclusion as a repository