The nesting at play here is a bit much - can you flatten it easily? (Reduce to 2-3 levels of nested conditionals)