added code for logic programming 5