modified setLatestData method of js