add preview and refactor