Making the code more self-explanatory, added comments about complexity