Added safeTrim