Fix code problem after charles merged his code