Refined Trimming Functionality

Refined trimming functionality

Refined trimming functionality
Merged master fixed conflict.