fix bugs (amended by mistaking)