fixed issue #949 using @alexkirmse's patch