Three layer F-measure for pattern seems to be working. Test passed. Need to optimize code