There is a lot going on in this few lines of code. Do you mind adding comments?