Changed $tm to $ts as per code. Should never have been $tm