remove reduplicate test and remove useless variable