Added preview function on index page