Fixed issue #2 and issue #5