fixed truncate undefined error