rearanged code