A little refactoring
template idea using javascript