Swap order of if's to allow for exceptional handling of 500 errors