Small refactoring to preview functionality