using template to memorize forward flag