I agree with you, there should be some helper function that does that.