changes to make trim works with kth element

it's working now!!!!