Switch max_sp calculation order