Jesus made it clear that we can sin in our heart even if we do not actually commit the physical act. The point He is making is that God wants our heart, not just an empty compliance to a set of rules. Even our most intimate contemplation's are known to God. If God has our heart, He has everything.
“...but let your heart keep my commandments…” Prov.3