Modularized the security-type detection algorithm.