Change some logic in onPreviewFrame