added min pair finder. needs refactoring to be more reusable