Added commonPrefix function