bug fixed for #540