i added this check only to avoid a resource leak, the idea here was to dispose the handle if a valid one was returned