refined template matching and started to test paper implementation