refactored out the preview from controllers

made more general as a shared method, and removed the duplication from many controllers