remove un-needed code and fix bug