coredump by duplicate variables fixed

To Fix issue #2