Fix bug 212

@titanous I am not sure whether the code is what you need.