fixed #476 and #477