Functionnal version of cast.html