Moved a few lines of code around