A new algorithm for sign restrictions in vector autoregressions