version 2: available in javascript, python and php