You should cache <b>$preview</b> in a variable, and then use the variable. This will allow to move all of your properties/methods definitions to <b>inputData</b>.