fix NoneType error in template