Fixed bug mentioned in #891 #876