fix issue #2 and a bug