refactoring & one more prolog example