added preprocess and fixed bugs