that's quite hard to read this if statement, maybe split it a bit differently (ie. break down the if statement in several one-liner if statements each testing only one condition)