Added a more correct way to calculate the content length