Template fixed and extended (thanks to SachaMPS)