fixed bug #117 and #70