and return the right status code