fix compile error and get rid of redunant code
get rid of redunant code