beautify code and optimization logic

beautify code and optimization logic , it will more efficiency on deploy
combine !