implemented variable elimination