Cleaned up truncate, making it more pythonic and simplified the code