Rearrange templates so js doesn't get called twice. Removed extra local....

...js