Closed issue #16 and made some minor modifications