fix template match and add basic ouput