added multi-threading based on chunk sizes