New apdator trimming code for use with new parser
updated version