rewrite find() method in refsm.java