moved logic out to preview