Added validation and minor bug fix in preview