Your attitude toward the word of God is your attitude toward Jesus (Ps 37:4).
If your mind is filled with the Word of God, then it can't be filled with impure thoughts.