Functions to replace variable with ground terms