allow context to be passed into preview function