improved template
use semafor