update preview function