more refactor using trigger