re-implemented template, close #1489