Fix for issue #63

This would have fixed the problem I was having in issue #63
I see you have been working on that as well @yi12345 so there might be merge problems :(