It is really not clear indeed. Thus, I have just changed some variable naming and the comments. Could you please give a look at it?