 in this snippet, the function is called three times with the same result, almost. Perhaps you can get by with just one function call.