fix bug
FIX BUG AND REMOVE UNUSED CODE