Case statements are our friend.
More robust fd seeking.
It's all ok.