refactored preview component