fix/172-fix-error-handling
dev
Fix error handling so that the value in ret variable does not become corrupt.