Extract a function and add support for [limit].