changed structure of js, redid templates