Moved code block into proper location