added if clause to truncate logging after timestamp exceeds maxDuration