I hate logic in views but I think in this case it's not too bad