If it's used twice, then I opt to make it as function.  It may be useful to the future and I think a function is easier to read.