fixed issue where callbacks could be called twice on error