improved program-logic