refactor notifications handling