minor bug fix and preview functionality