One of the tragic stories in the Old Testament is that of David and Bath-sheba. We read: "And it came to pass, after the year was expired, at the time when kings go forth to battle, that David sent Joab, and his servants with him, and All Israel; and they destroyed the children of Ammon, and besieged Rabbah. But David tarried still at Jerusalem." (2 Samuel 11:1.)
We commonly believe that David's first mistake, leading to his eventual downfall of adultery and murder, was when he let his thoughts dwell on what he had seen as he walked upon the roof of the king's house. This obviously was a wrong decision and was a major factor contributing to his downfall.
It appears that the first mistake he made, however, was not being where he should have been. He should have been with his troops in battle, but instead he stayed home. Often our thoughts are fueled by the environment we are in. If we are in the right places, and where we are supposed to be, many evil and unworthy thoughts and eventual actions will never happen.