         }
         
         var messageClosed = ""
+        var totalPosts = 0
         //Now fetch the posts from the API
         for post in try apiClient.fetchQuestions(postsToCheck).items ?? [] {
-            if (post.closed_reason == nil)
+            if (totalPosts < totalToCheck && (post.closed_reason == nil && post.close_vote_count ?? 0 >= minCV && post.close_vote_count ?? 0 <= maxCV))
             {
 				messageClosed = messageClosed + "\nCV:\(post.close_vote_count ?? 0)   \(post.link?.absoluteString ?? "https://example.com")"
+                totalPosts = totalPosts + 1
             }
         }
         

                        threshold = maxThreshold
                    }
                }
            }
        }
        

//  Created by Ashish Ahuja on 05/03/17.
//  Copyright © 2017 Ashish Ahuja. All right reserved
//

//TODO:
// 1. Instead of printing the reports in chat send them to Sam's server

import Foundation
import SwiftStack
