Implementing KClosest FSM