added peak finding algorithm