fix minor bugs and delete unnecesary lines