A pattern for expanding functions