finished isPeak method