re-arranging the code