implemented gen_truth table() (ugly, needs to be refactored)