Added status code checking