refactored preprocess to be a class