added original function and tests