fixed issue #1 and a bug