remove function for nested term