apply err handling