updated functions.R with Hila's TR, LE, SP work