code done phase I

finalize the code for preliminary analysis