Sometimes the elegant implementation is a function