changed chunk size and fixed infinite loop problem