added Cirow's code.