fixed error #239 and #240