fix completionHandler bug; pull completionHandler out of inner loop