introduced priority in applying templates