added content length checking