added minmax element algorithm