Added findPrefix function