Fix issue 1176

close issue #1176 
close issue #1119