Extract status code check into separate functions