refactoring
use templates