fix error when trimming