fixed issue #4 thanks to brendand