Added extra validation for trim function