Fixed to issue #325

Hello, 
I have experienced the same problem like the one in issue #325. This is my fix to it.