localMax added; bug fixed;