patch from Carlos Canau