code cleaning and inserted custom triggers