I got it to work by doing this. For some reason, it wouldn't work until I separated the lines after the "then" on line 38.