improve trimming and splitting