some restructuring. preview added