clean up source code

delete unused variables, simplify process logic.