adding preview functionality