added check for free vars in heads