fixed issue #2 from dsully fork