setting up observer in js