restructure in js