Moved code to correct position