Rewrite TransformCmpt to be more compact and clean

Signed-off-by: MHesham <mhesham.fcis@gmail.com>