Completed solution. Corrected return order of edges - suffix must be before prefix match. Removed duplicate function.