trying to debug the preview function