first implementation of logic plan generation