rewrote with terms and literals etc