https://gist.github.com/kaspermeerts/781f0137b361b51224dcab7...
https://gist.github.com/kaspermeerts/b6f158b1278de307e48a200...
I just hacked it together, but I do think it's not unreadable code
hopefully your boolean conditionals are easier to read than that