Javascript nested object correction