I wonder if there's a more general way to solve this and the other if... have to think harder and in more detail about it :-)