added trimming functions