basic template matching implemented