remove unused code & optimize

remove unused code & optimize