JS functionality reimplemented to Template form