code is quite gross, but triple feature matching is correctly working