Sorry I had duplicated some code in the tep function.

More...