code rearanged