added some more logic behind truncation