Fixed global reference in 'preprocess' by moving to function arg