query error fixed and header added