More prolog work. Should be done now