applied fixes for issue #45

applied fixes for issue #45