Could you take the time to document this function? Specifically, the theory you're applying and any assumptions you've made would be nice to have.