Correcting js code to update notifications when their are new ones only