fixed issue #11 by using code submitted by jepp