why does apply throw an error?