extracted preview code
integrated new preview interface