togglePreview method for preview