This function is way more generic that it needs to be when it is in a Formula. Makes it harder to follow what is going on IMO.