Fix errors and improve createNotification function