Chomp and trim functions