updated variable elimination to consider conditions also
corrections maybe