Peak finding algorithm