Docs and credits to original function author