corrected endsWith contains error in FSM