Added preprocess logic and corresponding testcases.