On your first loop you'll always get the bad end, then any loop afterwards has the chance to get the good end. On your 2nd loop (or whichever you're on right now), whenever you get the choice, be oppositional to Niles, don't agree with him.