Corrected javascript layout with new template layout