Un-nested the function so as to conform to the project's coding style.