returning err code along with result.

returning err code along with result.

returning err code along with result.

destructor added.

Change the order of dec