refactor notify code