Fixed buffering issue in template