fixed check for -1
removed usage of 'headers' field