findMin and findMax implementation