fixes findmin and findmax. Too many cases to check for in the basecase