Changed "if string ends with" to quicker tirm() call