implemented trim function