I think original success/error array should be enough here, you can push the result object into success/error array. Therefore you don't have to check the result is success or error in the loop.