fixed a bug in template helper