Fix bug in peaks detector