Added helper function to build preview