made "ts" method more stable for null and empty values