Moved distance calculation to model specification
Call match() in keyPressed() not in setup()
Renamed objective function for clarity
Removed variables from outside model
Updated version