added function preprocess_input()