fixed #499, #509