improved previous commit with TF code