Heh, this is quite hard to parse through. In this case, I recommend optimizing this for ease of reading via simple if else checks instead of a one liner.