added 'closest state' feature