clean getPreview function