Moved code to correct place