more complex version and now I add the original intention of the code based on what I believe