Preprocessing stage 1