This statement is very complex, I suggest more clear indenting and comments on what this statements does.