Code refactor

refactor all the codes