As well, it would be great to have a utility function for this? This code is duplicated 3 times.