fixed issue with sending chunks instead of remaining bytes