move http status code check to better place