Restructured like this for the purpose of less indentation.