We had this problem with an XJ, and the solution for us was to adjust the linkage between the 4wd shifting lever and the transfter case. Underneath the vehicle, there's a rod maybe 1.5ft long that attaches to the handle on one end, and the other end attaches to another rod sticking out of the transmission which levers a third rod which connects back to the transfter case. Where rod 1 (handle rod) connects to rod 2 (transmission rod), there's a bolt 13mm I think, that is used for adjustments. On my 96 XJ, and on a friends 98, the amount of extra that sticks out beyond that adjustment bolt, was about 1.25 inches. If that bolt isn't tight enough, it may shift fine one way, and then loosen going the other direction. That fixed the problem with our vehicle, I hope it helps(if that's it, it's really not as complicated as I made it sound). Good luck.