updated code for better previews